package com.platform.hjt.sys.model.json;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializerProvider;

import com.platform.hjt.sys.model.SysPosition;

public class SysPositionSerialize extends JsonSerializer<SysPosition>{

	@Override
	public void serialize(SysPosition sysPosition, JsonGenerator jgen,
			SerializerProvider arg2) throws IOException,
			JsonProcessingException {
		ObjectMapper om = new ObjectMapper();
		Map<String, String> map = new HashMap<String, String>();
		map.put("positionId", sysPosition.getPositionId());
		map.put("positionName", sysPosition.getPositionName());
		map.put("fullPinyin", sysPosition.getFullPinyin());
		map.put("shortPinyin", sysPosition.getShortPinyin());
		map.put("superId", sysPosition.getSysPosition()!=null?sysPosition.getSysPosition().getPositionId():"");
		om.writeValue(jgen, map);
	}
	
}
